﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using quanlyktx.quanlysinhvien;
using quanlyktx.quanlythuchi;
using quanlyktx.hethong;
using quanlyktx.quanlyphong;
using System.Data.SqlClient;

namespace quanlyktx
{
    public partial class frmmain : DevComponents.DotNetBar.Office2007RibbonForm 
    {
        public frmmain()
        {
            InitializeComponent();
        }
        ketnoi kn = new ketnoi();
        frmsinhvien sv = null;
        private void btsinhvien_Click(object sender, EventArgs e)
        {
            if (sv == null || sv.IsDisposed)
            {
                sv = new frmsinhvien();
                sv.MdiParent = this;
                sv.Show();
            }
            else
                sv.Activate();
        }
        frmlop lop = null;
        private void btdslop_Click(object sender, EventArgs e)
        {
            if (lop == null || lop.IsDisposed)
            {
                lop = new frmlop();
                lop.MdiParent = this;                
                lop.Show();
            }
            else
                lop.Activate();
        }
        frmkhoa khoa = null;
        private void btdskhoa_Click(object sender, EventArgs e)
        {
            if (khoa == null || khoa.IsDisposed)
            {
                khoa = new frmkhoa();
                khoa.MdiParent = this;
                khoa.Show();
            }
            else khoa.Activate();
        }
        frmtiendien tiendien = null;
        private void bttiendien_Click(object sender, EventArgs e)
        {
            if (tiendien == null || tiendien.IsDisposed)
            {
                tiendien = new frmtiendien();
                tiendien.MdiParent = this;
                tiendien.Show();
            }
            else
                tiendien.Activate();
        }
        frmtiennuoc tiennuoc = null;
        private void bttiennuoc_Click(object sender, EventArgs e)
        {
            if (tiennuoc == null || tiennuoc.IsDisposed)
            {
                tiennuoc = new frmtiennuoc();
                tiennuoc.MdiParent = this;
                tiennuoc.Show();
            }
            else tiennuoc.Activate();
        }
        frmtienphong tienphong = null;
        private void bttienphong_Click(object sender, EventArgs e)
        {
            if (tienphong == null || tienphong.IsDisposed)
            {
                tienphong = new frmtienphong();
                tienphong.MdiParent = this;
                tienphong.Show();
            }
            else
                tienphong.Activate();
        }

        private void bthelp_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.HelpProvider hlppro = new System.Windows.Forms.HelpProvider();
            hlppro.SetShowHelp(this, true);
            //help file
            hlppro.HelpNamespace = "Nhom 3 nguoi.docx";
        }
        private DataTable dtNV = new DataTable();
        private SqlDataAdapter da = new SqlDataAdapter();
        public static string msNV = "", tenNV = "";
        public void enableFormMain(string masoNV)
        {
            msNV = masoNV;
            SqlConnection cn = kn.taokn();
            cn.Open();
            // SqlCommand cmd = new SqlCommand("laynhanvien", cn);
            //SqlDataAdapter da = new SqlDataAdapter(cmd);


            //da.Fill(dtNV);

            //if (dtNV.Rows[0]["tennhanvien"].ToString() != msNV)
            //{
            //rbphong.Enabled = false;
            //rbquanly.Enabled = false;
            SqlCommand cmdten = new SqlCommand("timnhanvien", cn);
            cmdten.CommandType = CommandType.StoredProcedure;
            cmdten.Parameters.Add("@tendn", SqlDbType.NVarChar).Value = msNV;

            // cmdten.ExecuteNonQuery();
            //cmd.Dispose();
            da.SelectCommand = cmdten;
            da.Fill(dtNV);
            tenNV = dtNV.Rows[0]["tendn"].ToString();
            // stBar.Panels[0].Text = "mã NV:" + msNV;
            stBar.Panels[0].Text = "Nhân viên:" + tenNV;
            stBar.Panels[1].Text = "Hôm nay:" + DateTime.Now.ToShortDateString();
            //}
            //else
            //{

            //}


        }
        frmdmphong dmphong = null;
        private void buttonItem2_Click(object sender, EventArgs e)
        {
            if (dmphong == null || dmphong.IsDisposed)
            {
                dmphong = new frmdmphong();
                dmphong.MdiParent = this;
                dmphong.Show();
            }
            else
                dmphong.Activate();
        }
        frmthietbi thietbi = null;
        private void btthietbi_Click(object sender, EventArgs e)
        {
            if (thietbi == null || thietbi.IsDisposed)
            {
                thietbi = new frmthietbi();
                thietbi.MdiParent = this;
                thietbi.Show();

            }
            else thietbi.Activate();
        }

    }
}
